<template>
  <header>
    <div class="content-left">
      <el-button type="primary" icon="el-icon-menu" @click="collapseMenu">
      </el-button>
      <el-breadcrumb separator="/">
        <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
        <el-breadcrumb-item :to="current.path" v-if="current">
           {{ current.lable }} 
          </el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <div class="content-right">
      <el-dropdown>
        <span class="el-dropdown-link">
          <img :src="userImg" alt="用户头像" class="avatar">
        </span>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item>个人中心</el-dropdown-item>
          <el-dropdown-item @click.native="loout">退出</el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
    </div>
  </header>
</template>
<script>
import { mapState } from 'vuex'
export default {
  name: 'CommonHeader',
  data() {
    return {
      userImg: require('../assets/img/01.png')
    }
  },
  methods: {
    //搜索菜单
   collapseMenu () {
      this.$store.commit('collapseMenu')
    },
    // tuchu(){
    //   localStorage.removeItem('token')
    // },
    loout(){
      this.$store.commit('clearToken')
      this.$store.commit('claerMenu')
      location.reload()
    }
  },
  computed: {
    ...mapState({
      current: state => state.tab.currentMenu
    })
  }
}
</script>
<style lang="scss" scoped>
  header {
    display: flex;
    height: 100%;
    align-items: center;
    justify-content: space-between;
    margin: 0 10px;
  }

  .el-dropdown {
    color: #fff;
  }

  .content-left {
    width: 30%;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    .bread-title {
      color: #fff;
    }
    .el-button {
      margin-right: 20px;
    }
  }

  .content-right {
    .avatar {
      width: 48px;
      height: 48px;
      border-radius: 50%;
    }
  }
</style>